import { httpClient } from '@/utils/http/axios';
import { ErrorMessageMode } from '#/axios';
import { AjaxResult } from '@/api/model';
import { PageRequest, PageData } from '@/utils/common/types';
import { InputDto, OutputDto } from './productcarousel.data';

enum Api {
  Read = '/api/admin/productcarousel/read',
  Create = '/api/admin/productcarousel/create',
  Update = '/api/admin/productcarousel/update',
  Delete = '/api/admin/productcarousel/delete',
}

export function Read(request: PageRequest, mode: ErrorMessageMode = 'message') {
  return httpClient.post<PageData<OutputDto>>(
    {
      url: Api.Read,
      params: request,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function Create(dtos: InputDto[], mode: ErrorMessageMode = 'message') {
  return httpClient.post<AjaxResult>(
    {
      url: Api.Create,
      params: dtos,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function Update(dtos: InputDto[], mode: ErrorMessageMode = 'message') {
  return httpClient.post<AjaxResult>(
    {
      url: Api.Update,
      params: dtos,
    },
    {
      errorMessageMode: mode,
    },
  );
}

export function Delete(ids: string[], mode: ErrorMessageMode = 'message') {
  return httpClient.post<AjaxResult>(
    {
      url: Api.Delete,
      params: ids,
    },
    {
      errorMessageMode: mode,
    },
  );
}
